Skip to content

PYTHON 5790 Standardize references to test collections in tests - #3026

Open
sleepyStick wants to merge 13 commits into
mongodb:mainfrom
sleepyStick:PYTHON-5790
Open

PYTHON 5790 Standardize references to test collections in tests#3026
sleepyStick wants to merge 13 commits into
mongodb:mainfrom
sleepyStick:PYTHON-5790

Conversation

@sleepyStick

Copy link
Copy Markdown
Contributor

PYTHON-5790

Changes in this PR

renamed the following

  • db.test -> db.coll
  • self.db.test -> self.db.coll
  • client.test.test -> client.db.coll
  • client.pymongo_test.test -> client.pymongo_test.coll

basically collections named test in our tests are now named coll

Test Plan

Checklist

Checklist for Author

  • [NA] Did you update the changelog (if necessary)?
  • Is there test coverage?
  • [NA] Is any followup work tracked in a JIRA ticket? If so, add link(s).

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sleepyStick
sleepyStick marked this pull request as ready for review September 1, 2026 16:23
@sleepyStick
sleepyStick requested a review from a team as a code owner September 1, 2026 16:23
@sleepyStick
sleepyStick requested review from aclark4life and a lite review from Copilot September 1, 2026 16:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes many test collection references by renaming usages of collections named test to coll across the test suite (and updates associated command assertions / setup-cleanup) to reduce ambiguity and improve consistency in tests.

Changes:

  • Renamed many test collection attribute accesses from .test to .coll (and related variants like .test2.coll2) across synchronous and asynchronous tests.
  • Updated expected command documents / namespace assertions to reflect the new collection names (e.g., "find": "coll", "ns": "pymongo_test.coll").
  • Adjusted some test setup/cleanup to create/drop or clean the renamed collections, and updated a _csot.py doc example.

Reviewed changes

Copilot reviewed 84 out of 85 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pymongo/_csot.py Update timeout-context doc example to use client.db.coll.
test/utils_shared.py Update lazy-client trial helper to use pymongo_test.coll.
test/test_versioned_api_integration.py Use client.db.coll and update explicit find command to "coll".
test/test_typing.py Update typing tests to use client.db.coll* collections.
test/test_transactions.py Rename test collection usages to coll variants.
test/test_ssl.py Update x509 auth tests to query pymongo_test.coll.
test/test_session.py Rename collection references used in session tests to coll.
test/test_server_selection.py Switch server-selection test to operate on client.db.coll.
test/test_server_selection_in_window.py Rename server selection “prose” test collections to client.db.coll.
test/test_sdam_monitoring_spec.py Use self.client.db.name + .coll for SDAM monitoring spec setup.
test/test_retryable_writes.py Update retryable write tests to use coll collection references.
test/test_retryable_reads.py Update retryable read tests to use coll collection references.
test/test_read_write_concern_spec.py Rename db.test usage to db.coll and related collection-creation calls.
test/test_read_preferences.py Rename many read-preference tests from test collection to coll.
test/test_read_concern.py Create/drop coll collection for read-concern command assertions.
test/test_raw_bson.py Prefer self.db and rename collection cleanup/usages accordingly.
test/test_pooling.py Rename pooling test collections from test to coll.
test/test_monitoring.py Rename monitoring tests from test to coll and update expected commands/namespaces.
test/test_max_staleness.py Rename collection writes to pymongo_test.coll and add cleanup.
test/test_logger.py Rename logger tests to use db.coll and add collection drop in teardown.
test/test_load_balancer.py Rename load-balancer tests to use self.db.coll.
test/test_json_util_integration.py Rename JSON util integration tests to use db.coll and add cleanup.
test/test_index_management.py Rename index management tests to use client.db.coll.
test/test_grid_file.py Use bracket DB access (client["pymongo_test"]) for no-connect gridfs tests.
test/test_encryption.py Rename encryption integration tests to use coll and update schema-map namespaces.
test/test_discovery_and_monitoring.py Rename discovery/monitoring tests to use db.coll.
test/test_decimal128.py Rename Decimal128 integration test collection to pymongo_test.coll.
test/test_database.py Rename database API tests from test collection to coll where applicable.
test/test_custom_types.py Rename custom-type tests from test collection to coll.
test/test_csot.py Rename CSOT change stream test collection to db.coll and add cleanup.
test/test_common.py Rename db.test usage to db.coll and add cleanup for the upsert boolean validation test.
test/test_comment.py Rename comment helper test to use collection "coll".
test/test_collation.py Rename collation tests to use coll collections and update helpers accordingly.
test/test_client.py Rename various client tests to use coll and replace some client.pymongo_test usage with self.db.
test/test_client_backpressure.py Rename backpressure spec tests to use db.coll and update db.command("find", ...) args.
test/test_bulk.py Rename bulk tests and authz resources to reference "coll".
test/test_auth.py Rename auth tests to use db.coll / ldap.coll where appropriate.
test/mypy_fails/typedict_client.py Update mypy-fail fixture to use client.db.coll.
test/mypy_fails/raw_bson_document.py Update mypy-fail fixture to use client.db.coll.
test/mypy_fails/insert_one_list.py Update mypy-fail fixture to use client.db.coll.
test/mypy_fails/insert_many_dict.py Update mypy-fail fixture to use client.db.coll.
test/mockupdb/test_cursor_namespace.py Rename mockupdb cursor/killCursors namespace tests to use coll.
test/atlas/test_connection.py Rename Atlas connection smoke test to count docs in client.db.coll.
test/asynchronous/test_versioned_api_integration.py Async parity: use client.db.coll and "coll" in explicit find command.
test/asynchronous/test_transactions.py Async parity: rename collections to coll variants.
test/asynchronous/test_ssl.py Async parity: query pymongo_test.coll in x509 auth tests.
test/asynchronous/test_session.py Async parity: rename session test collections to coll.
test/asynchronous/test_server_selection.py Async parity: switch server-selection test to client.db.coll.
test/asynchronous/test_server_selection_in_window.py Async parity: rename prose test collection to client.db.coll.
test/asynchronous/test_sdam_monitoring_spec.py Async parity: use .coll for SDAM monitoring spec setup.
test/asynchronous/test_retryable_writes.py Async parity: update retryable write tests to use coll.
test/asynchronous/test_retryable_reads.py Async parity: update retryable read tests to use coll.
test/asynchronous/test_read_write_concern_spec.py Async parity: rename db.test usage to db.coll.
test/asynchronous/test_read_preferences.py Async parity: rename read-preference tests to coll where applicable.
test/asynchronous/test_read_concern.py Async parity: create/drop coll and reset listener post-creation.
test/asynchronous/test_raw_bson.py Async parity: prefer self.db and update collection cleanup/usages.
test/asynchronous/test_pooling.py Async parity: rename pooling tests to use db.coll.
test/asynchronous/test_monitoring.py Async parity: rename monitoring tests to coll and update expected commands/namespaces.
test/asynchronous/test_max_staleness.py Async parity: rename collection writes to pymongo_test.coll and add cleanup.
test/asynchronous/test_logger.py Async parity: rename logger tests to db.coll and drop in async teardown.
test/asynchronous/test_load_balancer.py Async parity: rename load-balancer tests to use self.db.coll.
test/asynchronous/test_json_util_integration.py Async parity: rename JSON util integration tests to db.coll and add cleanup.
test/asynchronous/test_index_management.py Async parity: rename index management tests to use client.db.coll.
test/asynchronous/test_grid_file.py Async parity: bracket DB access for no-connect gridfs tests.
test/asynchronous/test_encryption.py Async parity: rename encryption tests to coll and update schema-map namespaces.
test/asynchronous/test_discovery_and_monitoring.py Async parity: rename discovery/monitoring tests to use db.coll.
test/asynchronous/test_database.py Async parity: rename database API tests from test collection to coll where applicable.
test/asynchronous/test_custom_types.py Async parity: rename custom-type tests from test collection to coll.
test/asynchronous/test_csot.py Async parity: rename CSOT change stream test collection to db.coll and add cleanup.
test/asynchronous/test_concurrency.py Async parity: rename concurrency test collection to db.coll.
test/asynchronous/test_common.py Async parity: rename db.test usage to db.coll and add cleanup.
test/asynchronous/test_comment.py Async parity: rename comment helper test to use "coll".
test/asynchronous/test_collation.py Async parity: rename collation tests to use coll collections.
test/asynchronous/test_client.py Async parity: rename various client tests to use coll and replace some client.pymongo_test usage with self.db.
test/asynchronous/test_client_backpressure.py Async parity: rename backpressure spec tests to use db.coll and update command args.
test/asynchronous/test_bulk.py Async parity: rename bulk tests and authz resources to reference "coll".
test/asynchronous/test_auth.py Async parity: rename auth tests to use db.coll / ldap.coll.
test/asynchronous/test_async_contextvars_reset.py Async parity: rename contextvars reset test collection to db.coll.
test/asynchronous/test_async_cancellation.py Async parity: rename cancellation tests to use db.coll.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/asynchronous/test_read_preferences.py Outdated
Comment thread test/asynchronous/test_transactions.py Outdated
async def test_in_transaction_property(self):
client = async_client_context.client
coll = client.test.testcollection
coll = client.db.collcollection
Comment thread test/test_read_preferences.py Outdated
coll = client_context.client.pymongo_test.get_collection(
"test", write_concern=WriteConcern(w=num_members)
)
coll = self.db.get_collection("test", write_concern=WriteConcern(w=num_members))
Comment thread test/test_transactions.py Outdated
def test_in_transaction_property(self):
client = client_context.client
coll = client.test.testcollection
coll = client.db.collcollection

@aclark4life aclark4life left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good thanks! Added some missed "test" collection comments and these are missed but not in the PR:

  • test/test_threads.py:115,119
  • test/test_collection.py:174

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ client.test.test missed?

Comment thread test/asynchronous/test_load_balancer.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed self.db.test ^

Comment thread test/utils_shared.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db.test missed ^

Comment thread test/test_typing.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed db.test ^

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed db.test ^

Comment thread test/asynchronous/test_collection.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed self.db.test ^

Comment thread test/asynchronous/test_collection.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed "test" ^

@sleepyStick

Copy link
Copy Markdown
Contributor Author

@aclark4life thanks for raising them all! I think i changed them all but lmk if i missed any!! Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants